package com.hmall.order.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {
    /**
     * 配置交换机
     */
    @Bean
    public DirectExchange directExchange(){
        return ExchangeBuilder.directExchange("direct.order").delayed().durable(true).build();
    }
    /**
     * 订单延迟队列
     */
    @Bean
    public Queue delayQueue(){
       return new Queue("delay.queue",true);
    }
    /**
     * 绑定交换机
     */
    @Bean
    public Binding delayQueueBinding(){
        return BindingBuilder.bind(delayQueue()).to(directExchange()).with("order.delay.queue");
    }
}
